package com.ck.controller.teacher;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import com.ck.domain.Xuanze;
import com.ck.service.QuestionService;

public class RemoveXuanzeImageController extends AbstractController {
	
	private QuestionService questionService;

	public void setQuestionService(QuestionService questionService) {
		this.questionService = questionService;
	}

	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		Map model = new HashMap();
		
		Integer xuanzeID = Integer.parseInt(request.getParameter("xuanzeID"));
		Xuanze xuanze = questionService.gainXuanze(xuanzeID);
		
		boolean isRemoveSuccess = questionService.removeXuanzeImage(request, xuanze, model);
		
		if(isRemoveSuccess){
			return new ModelAndView("teacher/removeImageSuccess");
		}else{
			return new ModelAndView("teacher/removeImageFailed", model);
		}
	}
}
